﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using SilentVoice.Business;
using SilentVoice.Models;
using SilentVoice.ServiceObjects;

namespace SilentVoice.Service.Controllers
{
    [Authorize]
    public class EventsController : ApiController
    {
        private Manager manager;

        public EventsController()
        {
            manager = new Manager();
        }

        // GET api/events
        public IEnumerable<string> Get()
        {
            return new string[] { "value1", "value2" };
        }

        // GET api/events/5
        public ServiceEvent Get(int id)
        {
            return new ServiceEvent(manager.GetEvent(id));
        }

        // POST api/events
        public ServiceEvent Post(ServiceEvent svEvent)
        {
            return new ServiceEvent(manager.CreateEvent(svEvent.Event));
        }

        // PUT api/events/5
        public ServiceEvent Put(int id, ServiceEvent svEvent)
        {
            return new ServiceEvent(manager.UpdateEvent(svEvent.Event));
        }

        // DELETE api/events/5
        public ServiceEvent Delete(int id)
        {
            return new ServiceEvent(manager.DeleteEvent(new Event() { Id = id }));
        }

        public ServiceScratchpad Scratchpad(int id)
        {
            return new ServiceScratchpad(manager.GetScratchPadForEvent(new Event() { Id = id }));
        }
    }
}
